package com.whitehatsec.sentineldataexchange;

/**
 *
 * @author Kevin Overcash
 * Copyright 2010 WhiteHat Security
 */



import com.whitehatsec.sentineldataexchange.model.WhiteHatSite;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;

// Handler class for the SAXParser XML parser
// provides methods to populate the details of a single site
//
public class WhiteHatSiteDetailLoader   extends DefaultHandler
{
    private WhiteHatSite tempSite = new WhiteHatSite();
    private String tempVal = null;

    // called by the SAXParser at the beginning of every XML element
    public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException
    {
        tempVal = "";
    }

    // called by the SAXParser at every chunk of character data
    public void characters(char[] ch, int start, int length) throws SAXException
    {
            tempVal = tempVal + new String(ch,start,length);
    }

    // called by the SAXParser at the end of every XML element
    public void endElement(String uri, String localName, String qName) throws SAXException
    {
        if(qName.equalsIgnoreCase("site_url"))
        {
            tempSite.setSiteURL(tempVal);
        }
    }

    public WhiteHatSite getSite() {
        return this.tempSite;
    }
}
